package api

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"you-ku-mgr/api-getaway/basic/config"
	"you-ku-mgr/api-getaway/basic/handler/request"
	__ "you-ku-mgr/api-getaway/basic/proto"
)

func CreateVideo(c *gin.Context) {

	var video request.CreateVideo
	err := c.ShouldBind(&video)
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code": 0,
			"msg":  "参数错误",
		})
		return
	}
	r, err := config.VideoClient.CreateVideo(c, &__.CreateVideoReq{
		Title:   video.Title,
		Content: video.Content,
		Status:  video.Status,
		Address: video.Address,
		Year:    video.Year,
		Image:   video.Image,
	})
	if err != nil {
		return
	}
	c.JSON(http.StatusOK, gin.H{
		"code": r.Code,
		"msg":  r.Msg,
	})

}
